package com.laf.manager.service.impl;

import com.laf.manager.dto.ParkingRule;
import com.laf.manager.repository.ParkingRuleRepository;
import com.laf.manager.service.ParkingRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author ygl
 * @create 2018-12-27
 * @DESCRIPTION
 **/
@Service
public class ParkingRuleServiceImpl implements ParkingRuleService {

    @Autowired
    private ParkingRuleRepository ruleRepository;


    @Override
    public ParkingRule findOne() {
        List<ParkingRule> list = ruleRepository.findList();
        if (CollectionUtils.isEmpty(list)) {
            return null;
        }
        return list.get(0);
    }

    @Override
    public int insert(Integer pointsPerYuan, Integer mostYuan,Integer frozenTime) {
        return ruleRepository.insert(pointsPerYuan,mostYuan,frozenTime);
    }

    @Override
    public int update(ParkingRule model) {
        return ruleRepository.update(model);
    }
}
